package cn.tianyun.pethome.basic.base.service.impl;


import cn.tianyun.pethome.basic.base.mapper.BaseMapper;
import cn.tianyun.pethome.basic.base.query.BaseQuery;
import cn.tianyun.pethome.basic.base.service.BaseService;
import cn.tianyun.pethome.basic.util.PageList;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;


public class BaseServiceImpl<T> implements BaseService<T> {
    @Autowired
    private BaseMapper<T> baseMapper;
    @Override
    public void add(T t) {
        baseMapper.add(t);
    }

    @Override
    public void update(T t) {
        baseMapper.update(t);
    }

    @Override
    public void delete(Long id) {
        baseMapper.delete(id);
    }

    @Override
    public T loadById(Long id) {
        return baseMapper.loadById(id);
    }

    @Override
    public List<T> loadAll() {
        return baseMapper.loadAll();
    }

    @Override
    public PageList<T> queryPage(BaseQuery query) {
        List<T> list = baseMapper.queryData(query);
        Long cont = baseMapper.queryCount(query);
        PageList<T> pageList = new PageList<>(list, cont);
        return pageList;
    }

    @Override
    public void batchdelete(List<Long> ids) {
        baseMapper.batchdelete(ids);
    }
}
